using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class SpecimenSourceCodesAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public SpecimenSourceCodesAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"ABS","AMN","ASP","BBL","BDY","BIFL","BLD","BLDA","BLDC","BLDV","BON","BPH","BPU","BRN","BRO","BRTH","CALC","CBLD","CDM","CNJT","CNL","COL","CSF","CTP","CUR","CVM","CVX","CYST","DIAF","DOSE","DRN","DUFL","EAR","EARW","ELT","ENDC","ENDM","EOS","EXHLD","EYE","FIB","FIST","FLT","FLU","GAS","GAST","GEN","GENC","GENL","GENV","HAR","IHG","ISLT","IT","LAM","LIQ","LN","LNA","LNV","LYM","MAC","MAR","MBLD","MEC","MILK","MLK","NAIL","NOS","ORH","PAFL","PAT","PLAS","PLB","PLC","PLR","PMN","PPP","PRP","PRT","PUS","RBC","RT","SAL","SEM","SER","SKM","SKN","SNV","SPRM","SPT","SPTC","SPTT","STL","STON","SWT","TEAR","THRB","THRT","TISG","TISPL","TISS","TISU","TLGI","TLNG","TSMI","TUB","ULC","UMB","UMED","UR","URC","URNS","URT","URTH","USUB","VOM","WAT","WBC","WICK","WND","WNDA","WNDD","WNDE","XXX"};
						validVersionCodes[HL7Version.v231] = new string[]{"ABS","AMN","ASP","BPH","BIFL","BLDA","BBL","BLDC","BPU","BLDV","BON","BRTH","BRO","BRN","CALC","CDM","CNL","CTP","CSF","CVM","CVX","COL","CBLD","CNJT","CUR","CYST","DIAF","DOSE","DRN","DUFL","EAR","EARW","ELT","ENDC","ENDM","EOS","RBC","EYE","EXHLD","FIB","FLT","FIST","FLU","GAS","GAST","GEN","GENC","GENL","GENV","HAR","IHG","IT","ISLT","LAM","WBC","LN","LNA","LNV","LIQ","LYM","MAC","MAR","MEC","MBLD","MLK","MILK","NAIL","NOS","ORH","PAFL","PAT","PRT","PLC","PLAS","PLB","PLR","PMN","PPP","PRP","PUS","RT","SAL","SEM","SER","SKN","SKM","SPRM","SPT","SPTC","SPTT","STON","STL","SWT","SNV","TEAR","THRT","THRB","TISS","TISG","TLGI","TLNG","TISPL","TSMI","TISU","TUB","ULC","UMB","UMED","URTH","UR","URC","URT","URNS","USUB","VOM","BLD","BDY","WAT","WICK","WND","WNDA","WNDE","WNDD","XXX"};
						validVersionCodes[HL7Version.v24] = new string[]{"ABS","AMN","ASP","BPH","BIFL","BLDA","BBL","BLDC","BPU","BLDV","BON","BRTH","BRO","BRN","CALC","CDM","CNL","CTP","CSF","CVM","CVX","COL","CBLD","BLDCO","CNJT","CUR","CYST","DIAF","DOSE","DRN","DUFL","EAR","EARW","ELT","ENDC","ENDM","EOS","RBC","EYE","EXG","EXHLD","FIB","FLT","FIST","FLU","GAS","GAST","GEN","GENC","GENL","GENV","HAR","IHG","IT","ISLT","LAM","WBC","LN","LNA","LNV","LIQ","LYM","MAC","MAR","MEC","MBLD","MLK","MILK","NAIL","NOS","ORH","PAFL","PAT","PRT","PLC","PLAS","PLB","PLR","PMN","PPP","PRP","PUS","RT","SAL","SEM","SMN","SER","SKN","SKM","SPRM","SPT","SPTC","SPTT","STON","STL","SWT","SNV","TEAR","THRT","THRB","TISS","TISG","TLGI","TLNG","TISPL","TSMI","TISU","TUB","ULC","UMB","UMED","URTH","UR","URC","URT","URNS","USUB","VOM","VITF","BLD","BDY","WAT","WICK","WND","WNDA","WNDE","WNDD","XXX"};
						validVersionCodes[HL7Version.v25] = new string[]{"ABS","AMN","ASP","BPH","BIFL","BLDA","BBL","BLDC","BPU","BLDV","BON","BRTH","BRO","BRN","CALC","CDM","CNL","CTP","CSF","CVM","CVX","COL","BLDCO","CNJT","CUR","CYST","DIAF","DOSE","DRN","DUFL","EAR","EARW","ELT","ENDC","ENDM","EOS","RBC","EYE","EXG","FIB","FLT","FIST","FLU","GAS","GAST","GEN","GENC","GENL","GENV","HAR","IHG","IT","ISLT","LAM","WBC","LN","LNA","LNV","LIQ","LYM","MAC","MAR","MEC","MBLD","MLK","MILK","NAIL","NOS","ORH","PAFL","PAT","PRT","PLC","PLAS","PLB","PLR","PMN","PPP","PRP","PUS","RT","SAL","SMN","SER","SKN","SKM","SPRM","SPT","SPTC","SPTT","STON","STL","SWT","SNV","TEAR","THRT","THRB","TISS","TISG","TLGI","TLNG","TISPL","TSMI","TISU","TUB","ULC","UMB","UMED","URTH","UR","URC","URT","URNS","USUB","VITF","VOM","BLD","BDY","WAT","WICK","WND","WNDA","WNDE","WNDD","XXX"};
						validVersionCodes[HL7Version.v251] = new string[]{"ABS","AMN","ASP","BPH","BIFL","BLDA","BBL","BLDC","BPU","BLDV","BON","BRTH","BRO","BRN","CALC","CDM","CNL","CTP","CSF","CVM","CVX","COL","BLDCO","CNJT","CUR","CYST","DIAF","DOSE","DRN","DUFL","EAR","EARW","ELT","ENDC","ENDM","EOS","RBC","EYE","EXG","FIB","FLT","FIST","FLU","GAS","GAST","GEN","GENC","GENL","GENV","HAR","IHG","IT","ISLT","LAM","WBC","LN","LNA","LNV","LIQ","LYM","MAC","MAR","MEC","MBLD","MLK","MILK","NAIL","NOS","ORH","PAFL","PAT","PRT","PLC","PLAS","PLB","PLR","PMN","PPP","PRP","PUS","RT","SAL","SMN","SER","SKN","SKM","SPRM","SPT","SPTC","SPTT","STON","STL","SWT","SNV","TEAR","THRT","THRB","TISS","TISG","TLGI","TLNG","TISPL","TSMI","TISU","TUB","ULC","UMB","UMED","URTH","UR","URC","URT","URNS","USUB","VITF","VOM","BLD","BDY","WAT","WICK","WND","WNDA","WNDE","WNDD","XXX"};
						validVersionCodes[HL7Version.v26] = new string[]{"ABS","AMN","ASP","BPH","BIFL","BLDA","BBL","BLDC","BPU","BLDV","BON","BRTH","BRO","BRN","CALC","CDM","CNL","CTP","CSF","CVM","CVX","COL","BLDCO","CNJT","CUR","CYST","DIAF","DOSE","DRN","DUFL","EAR","EARW","ELT","ENDC","ENDM","EOS","RBC","EYE","EXG","FIB","FLT","FIST","FLU","GAS","GAST","GEN","GENC","GENL","GENV","HAR","IHG","IT","ISLT","LAM","WBC","LN","LNA","LNV","LIQ","LYM","MAC","MAR","MEC","MBLD","MLK","MILK","NAIL","NOS","ORH","PAFL","PAT","PRT","PLC","PLAS","PLB","PLR","PMN","PPP","PRP","PUS","RT","SAL","SMN","SER","SKN","SKM","SPRM","SPT","SPTC","SPTT","STON","STL","SWT","SNV","TEAR","THRT","THRB","TISS","TISG","TLGI","TLNG","TISPL","TSMI","TISU","TUB","ULC","UMB","UMED","URTH","UR","URC","URT","URNS","USUB","VITF","VOM","BLD","BDY","WAT","WICK","WND","WNDA","WNDE","WNDD","XXX"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Abcess","Amniotic fluid","Aspirate","Blood bag","Whole body","Bile fluid","Whole blood","Blood  arterial","Blood  capillary","Blood  venous","Bone","Basophils","Blood product unit","Burn","Bronchial","Breath (use EXHLD)","Calculus (=Stone)","Cord blood","Cardiac muscle","Conjunctiva","Cannula","Colostrum","Cerebral spinal fluid","Catheter tip","Curettage","Cervical mucus","Cervix","Cyst","Dialysis fluid","Dose med or substance","Drain","Duodenal fluid","Ear","Ear wax (cerumen)","Electrode","Endocardium","Endometrium","Eosinophils","Exhaled gas (=breath)","Eye","Fibroblasts","Fistula","Filter","Body fluid, unsp","Gas","Gastric fluid/contents","Genital","Genital cervix","Genital lochia","Genital vaginal","Hair","Inhaled Gas","Isolate","Intubation tube","Lamella","Liquid NOS","Line","Line arterial","Line venous","Lymphocytes","Macrophages","Marrow","Menstrual blood","Meconium","Breast milk","Milk","Nail","Nose (nasal passage)","Other","Pancreatic fluid","Patient","Plasma","Plasma bag","Placenta","Pleural fluid (thoracentesis fld)","Polymorphonuclear neutrophils","Patelet poor plasma","Platelet rich plasma","Peritoneal fluid /ascites","Pus","Erythrocytes","Route of medicine","Saliva","Seminal fluid","Serum","Skeletal muscle","Skin","Synovial fluid (Joint fluid)","Spermatozoa","Sputum","Sputum - coughed","Sputum - tracheal aspirate","Stool = Fecal","Stone (use CALC)","Sweat","Tears","Thrombocyte (platelet)","Throat","Tissue gall bladder","Tissue placenta","Tissue","Tissue ulcer","Tissue large intestine","Tissue lung","Tissue small intestine","Tube NOS","Ulcer","Umbilical blood","Unknown medicine","Urine","Urine clean catch","Urine sediment","Urine catheter","Urethra","Unknown substance","Vomitus","Water","Leukocytes","Wick","Wound","Wound abscess","Wound drainage","Wound exudate","To be specified in another part of the message"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Abscess","Amniotic fluid","Aspirate","Basophils","Bile fluid","Blood  arterial","Blood bag","Blood  capillary","Blood product unit","Blood  venous","Bone","Breath (use EXHLD)","Bronchial","Burn","Calculus (=Stone)","Cardiac muscle","Cannula","Catheter tip","Cerebral spinal fluid","Cervical mucus","Cervix","Colostrum","Cord blood","Conjunctiva","Curettage","Cyst","Dialysis fluid","Dose med or substance","Drain","Duodenal fluid","Ear","Ear wax (cerumen)","Electrode","Endocardium","Endometrium","Eosinophils","Erythrocytes","Eye","Exhaled gas (=breath)","Fibroblasts","Filter","Fistula","Body fluid, unsp","Gas","Gastric fluid/contents","Genital","Genital cervix","Genital lochia","Genital vaginal","Hair","Inhaled Gas","Intubation tube","Isolate","Lamella","Leukocytes","Line","Line arterial","Line venous","Liquid NOS","Lymphocytes","Macrophages","Marrow","Meconium","Menstrual blood","Milk","Breast milk","Nail","Nose (nasal passage)","Other","Pancreatic fluid","Patient","Peritoneal fluid /ascites","Placenta","Plasma","Plasma bag","Pleural fluid (thoracentesis fld)","Polymorphonuclear neutrophils","Patelet poor plasma","Platelet rich plasma","Pus","Route of medicine","Saliva","Seminal fluid","Serum","Skin","Skeletal muscle","Spermatozoa","Sputum","Sputum - coughed","Sputum - tracheal aspirate","Stone (use CALC)","Stool = Fecal","Sweat","Synovial fluid (Joint fluid)","Tears","Throat","Thrombocyte (platelet)","Tissue","Tissue gall bladder","Tissue large intestine","Tissue lung","Tissue placenta","Tissue small intestine","Tissue ulcer","Tube NOS","Ulcer","Umbilical blood","Unknown medicine","Urethra","Urine","Urine clean catch","Urine catheter","Urine sediment","Unknown substance","Vomitus","Whole blood","Whole body","Water","Wick","Wound","Wound abscess","Wound exudate","Wound drainage","To be specified in another part of the 422.3.10070message"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Abscess","Amniotic fluid","Aspirate","Basophils","Bile fluid","Blood  arterial","Blood bag","Blood  capillary","Blood product unit","Blood  venous","Bone","Breath (use EXHLD)","Bronchial","Burn","Calculus (=Stone)","Cardiac muscle","Cannula","Catheter tip","Cerebral spinal fluid","Cervical mucus","Cervix","Colostrum","Cord blood","Cord blood","Conjunctiva","Curettage","Cyst","Dialysis fluid","Dose med or substance","Drain","Duodenal fluid","Ear","Ear wax (cerumen)","Electrode","Endocardium","Endometrium","Eosinophils","Erythrocytes","Eye","Exhaled gas (=breath)","Exhaled gas (=breath)","Fibroblasts","Filter","Fistula","Body fluid, unsp","Gas","Gastric fluid/contents","Genital","Genital cervix","Genital lochia","Genital vaginal","Hair","Inhaled Gas","Intubation tube","Isolate","Lamella","Leukocytes","Line","Line arterial","Line venous","Liquid NOS","Lymphocytes","Macrophages","Marrow","Meconium","Menstrual blood","Milk","Breast milk","Nail","Nose (nasal passage)","Other","Pancreatic fluid","Patient","Peritoneal fluid /ascites","Placenta","Plasma","Plasma bag","Pleural fluid (thoracentesis fld)","Polymorphonuclear neutrophils","Platelet poor plasma","Platelet rich plasma","Pus","Route of medicine","Saliva","Seminal fluid","Seminal fluid","Serum","Skin","Skeletal muscle","Spermatozoa","Sputum","Sputum - coughed","Sputum - tracheal aspirate","Stone (use CALC)","Stool = Fecal","Sweat","Synovial fluid (Joint fluid)","Tears","Throat","Thrombocyte (platelet)","Tissue","Tissue gall bladder","Tissue large intestine","Tissue lung","Tissue placenta","Tissue small intestine","Tissue ulcer","Tube NOS","Ulcer","Umbilical blood","Unknown medicine","Urethra","Urine","Urine clean catch","Urine catheter","Urine sediment","Unknown substance","Vomitus","Vitreous Fluid","Whole blood","Whole body","Water","Wick","Wound","Wound abscess","Wound exudate","Wound drainage","To be specified in another part of the message"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Abscess","Amniotic fluid","Aspirate","Basophils","Bile fluid","Blood  arterial","Blood bag","Blood  capillary","Blood product unit","Blood  venous","Bone","Breath (use EXHLD)","Bronchial","Burn","Calculus (=Stone)","Cardiac muscle","Cannula","Catheter tip","Cerebral spinal fluid","Cervical mucus","Cervix","Colostrum","Cord blood","Conjunctiva","Curettage","Cyst","Dialysis fluid","Dose med or substance","Drain","Duodenal fluid","Ear","Ear wax (cerumen)","Electrode","Endocardium","Endometrium","Eosinophils","Erythrocytes","Eye","Exhaled gas (=breath)","Fibroblasts","Filter","Fistula","Body fluid, unsp","Gas","Gastric fluid/contents","Genital","Genital cervix","Genital lochia","Genital vaginal","Hair","Inhaled Gas","Intubation tube","Isolate","Lamella","Leukocytes","Line","Line arterial","Line venous","Liquid NOS","Lymphocytes","Macrophages","Marrow","Meconium","Menstrual blood","Milk","Breast milk","Nail","Nose (nasal passage)","Other","Pancreatic fluid","Patient","Peritoneal fluid /ascites","Placenta","Plasma","Plasma bag","Pleural fluid (thoracentesis fld)","Polymorphonuclear neutrophils","Platelet poor plasma","Platelet rich plasma","Pus","Route of medicine","Saliva","Seminal fluid","Serum","Skin","Skeletal muscle","Spermatozoa","Sputum","Sputum - coughed","Sputum - tracheal aspirate","Stone (use CALC)","Stool = Fecal","Sweat","Synovial fluid (Joint fluid)","Tears","Throat","Thrombocyte (platelet)","Tissue","Tissue gall bladder","Tissue large intestine","Tissue lung","Tissue placenta","Tissue small intestine","Tissue ulcer","Tube NOS","Ulcer","Umbilical blood","Unknown medicine","Urethra","Urine","Urine clean catch","Urine catheter","Urine sediment","Unknown substance","Vitreous Fluid","Vomitus","Whole blood","Whole body","Water","Wick","Wound","Wound abscess","Wound exudate","Wound drainage","To be specified in another part of the message"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Abscess","Amniotic fluid","Aspirate","Basophils","Bile fluid","Blood  arterial","Blood bag","Blood  capillary","Blood product unit","Blood  venous","Bone","Breath (use EXHLD)","Bronchial","Burn","Calculus (=Stone)","Cardiac muscle","Cannula","Catheter tip","Cerebral spinal fluid","Cervical mucus","Cervix","Colostrum","Cord blood","Conjunctiva","Curettage","Cyst","Dialysis fluid","Dose med or substance","Drain","Duodenal fluid","Ear","Ear wax (cerumen)","Electrode","Endocardium","Endometrium","Eosinophils","Erythrocytes","Eye","Exhaled gas (=breath)","Fibroblasts","Filter","Fistula","Body fluid, unsp","Gas","Gastric fluid/contents","Genital","Genital cervix","Genital lochia","Genital vaginal","Hair","Inhaled Gas","Intubation tube","Isolate","Lamella","Leukocytes","Line","Line arterial","Line venous","Liquid NOS","Lymphocytes","Macrophages","Marrow","Meconium","Menstrual blood","Milk","Breast milk","Nail","Nose (nasal passage)","Other","Pancreatic fluid","Patient","Peritoneal fluid /ascites","Placenta","Plasma","Plasma bag","Pleural fluid (thoracentesis fld)","Polymorphonuclear neutrophils","Platelet poor plasma","Platelet rich plasma","Pus","Route of medicine","Saliva","Seminal fluid","Serum","Skin","Skeletal muscle","Spermatozoa","Sputum","Sputum - coughed","Sputum - tracheal aspirate","Stone (use CALC)","Stool = Fecal","Sweat","Synovial fluid (Joint fluid)","Tears","Throat","Thrombocyte (platelet)","Tissue","Tissue gall bladder","Tissue large intestine","Tissue lung","Tissue placenta","Tissue small intestine","Tissue ulcer","Tube NOS","Ulcer","Umbilical blood","Unknown medicine","Urethra","Urine","Urine clean catch","Urine catheter","Urine sediment","Unknown substance","Vitreous Fluid","Vomitus","Whole blood","Whole body","Water","Wick","Wound","Wound abscess","Wound exudate","Wound drainage","To be specified in another part of the message"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Abscess","Amniotic fluid","Aspirate","Basophils","Bile fluid","Blood  arterial","Blood bag","Blood  capillary","Blood product unit","Blood  venous","Bone","Breath (use EXHLD)","Bronchial","Burn","Calculus (=Stone)","Cardiac muscle","Cannula","Catheter tip","Cerebral spinal fluid","Cervical mucus","Cervix","Colostrum","Cord blood","Conjunctiva","Curettage","Cyst","Dialysis fluid","Dose med or substance","Drain","Duodenal fluid","Ear","Ear wax (cerumen)","Electrode","Endocardium","Endometrium","Eosinophils","Erythrocytes","Eye","Exhaled gas (=breath)","Fibroblasts","Filter","Fistula","Body fluid, unsp","Gas","Gastric fluid/contents","Genital","Genital cervix","Genital lochia","Genital vaginal","Hair","Inhaled Gas","Intubation tube","Isolate","Lamella","Leukocytes","Line","Line arterial","Line venous","Liquid NOS","Lymphocytes","Macrophages","Marrow","Meconium","Menstrual blood","Milk","Breast milk","Nail","Nose (nasal passage)","Other","Pancreatic fluid","Patient","Peritoneal fluid /ascites","Placenta","Plasma","Plasma bag","Pleural fluid (thoracentesis fld)","Polymorphonuclear neutrophils","Platelet poor plasma","Platelet rich plasma","Pus","Route of medicine","Saliva","Seminal fluid","Serum","Skin","Skeletal muscle","Spermatozoa","Sputum","Sputum - coughed","Sputum - tracheal aspirate","Stone (use CALC)","Stool = Fecal","Sweat","Synovial fluid (Joint fluid)","Tears","Throat","Thrombocyte (platelet)","Tissue","Tissue gall bladder","Tissue large intestine","Tissue lung","Tissue placenta","Tissue small intestine","Tissue ulcer","Tube NOS","Ulcer","Umbilical blood","Unknown medicine","Urethra","Urine","Urine clean catch","Urine catheter","Urine sediment","Unknown substance","Vitreous Fluid","Vomitus","Whole blood","Whole body","Water","Wick","Wound","Wound abscess","Wound exudate","Wound drainage","To be specified in another part of the message"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
